package org.pr.ddddesigner.infrastructure.config;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.info.License;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.web.ReactivePageableHandlerMethodArgumentResolver;
import org.springframework.web.reactive.config.WebFluxConfigurer;
import org.springframework.web.reactive.result.method.annotation.ArgumentResolverConfigurer;

/**
 * 接口文档配置
 *
 * @author bufanqi
 * @date 2021-08-18 16:08
 **/
@OpenAPIDefinition(
        info = @Info(
                title = "${spring.application.name}",
                version = "1.0.0",
                description = "OpenApi3.0",
                license = @License(name = "Apache 2.0", url = "http://www.apache.org/licenses/LICENSE-2.0.html")
        )
)
@Configuration
public class ModelConfiguration implements WebFluxConfigurer {
    @Value("${app.context-path}")
    private String contextPath;

    /*@Bean
    public GroupedOpenApi groupOpenApi() {
        String[] paths = {
                contextPath + "/model/**",
                contextPath + "/component/**",
        };
        String[] packagesToScan = {"com.xw.soonmanager.modelcomponent.interfaces.rest"};
        return GroupedOpenApi.builder().group("groups").pathsToMatch(paths).packagesToScan(packagesToScan)
                .build();
    }*/

    @Override
    public void configureArgumentResolvers(ArgumentResolverConfigurer configurer) {
        configurer.addCustomResolver(new ReactivePageableHandlerMethodArgumentResolver());
    }
}